<template>
  <router-view />
  <van-tabbar v-model="active">
    <van-tabbar-item icon="home-o" @click="forHomeIndex()">首页</van-tabbar-item>
    <van-tabbar-item icon="location" @click="forHMapIndex()">地图</van-tabbar-item>
    <van-tabbar-item icon="scan" @click="forHCodeIndex()">扫描</van-tabbar-item>
    <van-tabbar-item icon="coupon" @click="forHCouponIndex()">优惠券</van-tabbar-item>
    <van-tabbar-item icon="user" @click="forHMineIndex()">我的</van-tabbar-item>
  </van-tabbar>
</template>
<script setup>
import router from '@/router';
import { ref } from 'vue';

const active = ref(0);

function forHomeIndex(){
  router.push('/home/index');
}
function forHMapIndex(){
  router.push('/map/index');
}
function forHMineIndex(){
 var token = localStorage.getItem("token");
 console.info(token);
 //登录了就跳转到个人中心，否则就去登录
 if(token){
  router.push('/mine/index');
 }else{
      router.push('/user/login'); 
 }
}
function forHCouponIndex(){
  router.push('/coupon/index');
}
function forHCodeIndex(){ 
  
      router.push('/code/index'); 
}
</script>